﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="InsertImage.aspx.cs" Inherits="InsertImage" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Chèn hình</title>
    <link href="CSS/UserStyleSheet.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        body { overflow:hidden; width:800px }
    </style>
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <script language="javascript" type="text/javascript">
        function GetRadWindow() {
            var oWindow = null;
            if (window.radWindow) oWindow = window.radWindow;
            else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
            return oWindow;
        }

        function ConfigureDialog() {
            //Get a reference to the radWindow wrapper
            var oWindow = GetRadWindow();

            //Obtain the argument 
            var oArg = oWindow.Argument;

            //Use the argument
            var oArea = document.getElementById("DialogInfoArea");
            oArea.value = oArg.TextValue;
            oArea.style.color = oArg.Color;
            oArea.style.backgroundColor = oArg.BackColor;
        }

        function Cancel_Clicked() {
            var oWindow = GetRadWindow();

            //Get current content of text area
            var DialogInfo = document.getElementById("DialogInfoArea").value;
            var ImageURL = document.getElementById("txtImageURL").value;
            var height = document.getElementById("txtHeightUnit").value;
            var width = document.getElementById("txtWidthUnit").value;
            var oNewText = null;
            if (ImageURL != "") {
                oNewText = DialogInfo + "<img src=\"" + ImageURL + "\" height=\"" + height + "\" width=\"" + width + "\"/>";
            }
            else {
                oNewText = DialogInfo;
            }

            //Variant1: Passing the argument to the close method will result in the same behavior
            oWindow.close(oNewText);
        }
    </script>
    </telerik:RadCodeBlock>
</head>
<body onload="ConfigureDialog()">
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" Skin="Telerik"/>
    <div>
        <label id="DialogInfoArea" visible="false"></label>
        <input type="hidden" id="txtImageURL" runat="server" />
        <input type="hidden" id="txtHeightUnit" runat="server" />
        <input type="hidden" id="txtWidthUnit" runat="server" />
        <div id="div-choice">
            <table>
                <tr>
                    <td valign="middle"><img src="Images/computer.jpg" alt="Tải hình từ máy tính của bạn" width="64" height="64" /></td>
                    <td valign="middle">
                        <asp:RadioButton ID="rd1" runat="server" AutoPostBack="true" Checked="true" GroupName="group1" Text="Tải hình từ máy tính của bạn" />
                    </td>
                </tr>
                <tr>
                    <td valign="middle"><img src="Images/hyperlink.jpg" alt="Tải hình từ 1 đường link khác" width="64" height="64" /></td>
                    <td valign="middle"><asp:RadioButton ID="rd2" runat="server" AutoPostBack="true" GroupName="group1" Text="Tải hình từ 1 đường link khác" /></td>
                </tr>
            </table>
        </div>
        <div id="div_uploadform" runat="server" class="div-uploadform">
            <div id="uploadForm" runat="server">
                Tải hình từ máy tính : <telerik:RadUpload ID="RadUploadI1" runat="server" BackColor="#FFF8C6" Skin="Hay"
                    MaxFileInputsCount="1" AllowedFileExtensions=".jpg,.jpeg,.gif" Width="400px" style="float:left">
                </telerik:RadUpload>
            </div>
            <div id="urlForm" runat="server" visible="false">
                Nhập vào url : 
                <asp:TextBox ID="txtURL" runat="server" Width="250"></asp:TextBox>
            </div>
            <br />
            Chiều cao : 
            <asp:TextBox ID="txtHeight" runat="server" Width="70"></asp:TextBox>&nbsp;px&nbsp;&nbsp;
            Chiều rộng :
            <asp:TextBox ID="txtWidth" runat="server" Width="70"></asp:TextBox>&nbsp;px
            <br /><br />
            <asp:Button ID="btnUpload" runat="server" Text="Chèn hình" 
                onclick="btnUpload_Click" />&nbsp;&nbsp;
            <asp:Button ID="btnClose" runat="server" Text="Đóng cửa sổ" />
        </div>
    </div>
    </form>
</body>
</html>